<template>
	<div>
		<el-col :span="24">
			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>账号设置</span>
				</div>
				<el-form label-width="100px" class="demo-ruleForm">
					<el-form-item label="用户名：">
						<el-input v-model="username" :disabled="true"></el-input>
					</el-form-item>
					<el-form-item label="Email：">
						<el-input v-model="Email" :disabled="true"></el-input>
					</el-form-item>
					<el-form-item label="旧密码：">
						<el-input v-model="old_password"></el-input>
					</el-form-item>
					<el-form-item label="新密码：">
						<el-input v-model="new_password"></el-input>
					</el-form-item>
					<el-form-item label="确认新密码：">
						<el-input v-model="again_password"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" @click="submitForm()">修改</el-button>
					</el-form-item>
				</el-form>
			</el-card>
		</el-col>
	</div>
</template>

<script>
	import http from 'assets/js/http.js'
	export default {
		data() {
			return {
				username: '',
				Email: '',
				new_password: '',
				again_password: '',
				old_password: '',
			};
		},
		created() {
			this.init()
			_g.closeGlobalLoading()
		},
		methods: {
			submitForm() {
				if(this.new_password != this.again_password){
					_g.toastMsg('warning', '两次输入的密码不一致')
					return false;
				}
				let data = {
					old_password: this.old_password,
					password: this.new_password
				}
				let url = '/AdminApi/SystemSetting/admin_set'
				this.apiPost(url, data).then(res => {
					console.log('账号设置res', res)
					this.handelResponse(res, data => {
						_g.toastMsg('success', res.msg)
					})
				})
			},
			
			init() {
				// 基本数据获取
				this.tableData()
			},
			tableData() {
				// 表格数据
				const data = {
					
				}
				// 请求地址
				let url = '/AdminApi/SystemSetting/admin_set'
				this.apiPost(url, data).then(res => {
					console.log('账号res', res)
					this.handelResponse(res, data => {
						this.username = data.username
						this.Email = data.email
						
						_g.closeGlobalLoading()
					})
				})
			},
		},
		mixins: [http]
	}
</script>

<style scoped>
	.el-input,
	.el-input__inner {
		width: auto;
	}
</style>